package tests.jdl.databaseObjects.datatypes.postgreSql;

import jdl.databaseObjects.DbType;
import jdl.databaseObjects.DbTypeUnknownException;
import jdl.databaseObjects.datatypes.postgreSql.Int2DbType;
import jdl.databaseObjects.datatypes.postgreSql.Int4DbType;
import jdl.databaseObjects.datatypes.postgreSql.PostgreSqlDbTypeFactory;
import junit.framework.Assert;

import org.junit.Test;

public class PostgreSqlDbTypeFactory_Test {
	@Test
	public void fromString_typeIsInt2() throws DbTypeUnknownException {
		DbType type = PostgreSqlDbTypeFactory.fromString("int2");
		Assert.assertEquals(new Int2DbType(), type);
	}

	@Test(expected = DbTypeUnknownException.class)
	public void fromString_typeIsUnknown() throws DbTypeUnknownException {
		PostgreSqlDbTypeFactory.fromString("hello world");
	}

	@Test
	public void fromString_typeIsInt4() throws DbTypeUnknownException {
		DbType type = PostgreSqlDbTypeFactory.fromString("int4");
		Assert.assertEquals(new Int4DbType(), type);
	}
}
